<template>
    <div class="app-container">
        <div class="block">
            <el-row :gutter="20">
                <el-col :span="6">
                    <el-input v-model="listQuery.criteria.name" size="mini" placeholder="请输入名称"></el-input>
                </el-col>
                <el-col :span="6">
                    <el-button type="success" size="mini" icon="el-icon-search" @click.native="search">搜索</el-button>
                    <el-button type="primary" size="mini" icon="el-icon-refresh" @click.native="reset">重置</el-button>
                </el-col>
            </el-row>
            <br>
            <el-row>
                <el-col :span="24">
                    <el-button type="success" size="mini" icon="el-icon-plus" @click.native="add">添加</el-button>
                    <el-button type="primary" size="mini" icon="el-icon-edit" @click.native="edit">修改</el-button>
                    <el-button type="danger" size="mini" icon="el-icon-delete" @click.native="remove">删除</el-button>
                </el-col>
            </el-row>
        </div>


        <el-table :data="list" v-loading="listLoading" element-loading-text="Loading" border fit highlight-current-row
            @current-change="handleCurrentChange">
            <el-table-column type="expand">
                <template slot-scope="props">
                    <el-form label-position="left" inline class="demo-table-expand">
                        <el-form-item label="仓库名称">
                            <span>{{ props.row.name }}</span>
                        </el-form-item>
                        <el-form-item label="位置">
                            <span>{{ props.row.location }}</span>
                        </el-form-item>
                        <el-form-item label="负责人">
                            <span>{{ props.row.manager }}</span>
                        </el-form-item>
                        <el-form-item label="容量">
                            <span>{{ props.row.capacity }}</span>
                        </el-form-item>
                        <el-form-item label="已使用">
                            <span>{{ props.row.usedCapacity }}</span>
                        </el-form-item>
                        <el-form-item label="排序">
                            <span>{{ props.row.num }}</span>
                        </el-form-item>
                        <el-form-item label="说明">
                            <span>{{ props.row.remark }}</span>
                        </el-form-item>
                    </el-form>
                </template>
            </el-table-column>
            <el-table-column label="仓库名称" prop="name">
            </el-table-column>
            <el-table-column label="位置" prop="location">
            </el-table-column>
            <el-table-column label="负责人" prop="manager">
            </el-table-column>
            <el-table-column label="状态">
                <template slot-scope="scope">
          <el-switch v-model="scope.row.status==0"  @change="changeUserStatus(scope.row)"></el-switch>
        </template>
            </el-table-column>
            <el-table-column label="操作" min-width="50px">
                <template slot-scope="scope">
                    <el-button type="text" size="mini" icon="el-icon-edit" @click.native="editItem(scope.row)">
                        修改
                    </el-button>
                    <el-button type="text" size="mini" icon="el-icon-delete" @click.native="removeItem(scope.row)">
                        删除
                    </el-button>
                </template>
            </el-table-column>




        </el-table>

        <el-pagination background layout="total, sizes, prev, pager, next, jumper" :page-sizes="[10, 20, 50, 100, 500]"
            :page-size="listQuery.size" :total="total" :current-page.sync="listQuery.current" @size-change="changeSize"
            @current-change="fetchPage" @prev-click="fetchPrev" @next-click="fetchNext">
        </el-pagination>



        <el-dialog :title="formTitle" :visible.sync="formVisible" width="50%">
            <el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="right">
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="名称" prop="name">
                            <el-input v-model="form.name" minlength=1></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <el-form-item label="容量" prop="capacity">
                            <el-input type="number" v-model="form.capacity" minlength=1></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="24">
                        <el-form-item label="位置" prop="location">
                            <el-input v-model="form.location"></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="24">
                        <el-form-item label="负责人" prop="manager">
                            <el-input v-model="form.manager"></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="24">
                        <el-form-item label="说明" prop="remark">
                            <el-input v-model="form.remark"></el-input>
                        </el-form-item>
                    </el-col>

                    <el-col :span="24">
                        <el-form-item label="排序" prop="num">
                            <el-input v-model="form.num" type="number"></el-input>
                        </el-form-item>
                    </el-col>

                </el-row>
                <el-form-item>
                    <el-button type="primary" @click="save">提交</el-button>
                    <el-button @click.native="formVisible = false">取消</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>
    </div>
</template>

<script src="./house.js">
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
.demo-table-expand {
    margin-left: 20px;
    font-size: 0;
}

.demo-table-expand label {
    width: 90px;
    color: #99a9bf;
}

.demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 50%;
}
</style>
